{extend name="index/index" /}
{block name="main"}


{if condition = "$ses['vip'] eq 2"}
<img src="/static/index/img/vip_logo_2.png" width="48"><span style="color: darkviolet;">尊敬的会员：{$ses.name}</span>
{else/}
<p style="color: darkviolet;">尊敬的用户：{$ses.name}</p>
{/if}

<hr>
{volist name="book_data" id="v"}
<div style="width: 350px; display: inline-block;margin-left:20px;">
    <div class="row" style="position: relative">
        <div class="col-xs-6">
            <a href="">
                <img src="/uploads/{$v.pic}" width="180" height="240">
            </a>
        </div>
        <div class="col-xs-6">
            <p style="font-size:20px;">{$v.name}</p>
            <p>{$v.mark}</p>
            <br>
            <br>
            <br>
            <br>
            <br>
            <p>{$v.detail|mb_substr=0,10}</p>
            <br>
            <p>{$v.author}</p>
        </div>
        <button class="glyphicon glyphicon-remove del_btn" data-id={$v.id} style="color:red;position:absolute;top:0;right:10px;opacity: 0.2"></button>
    </div>
</div>
{/volist}


<script>
    $(function(){

        //    弹框参数
        toastr.options = {
            closeButton: true,
            progressBar: true,
            timeOut: "2000",
            positionClass: "toast-top-right"
        };
        //  触发删除按钮
        $('.del_btn').click(function(){
            var ac_id = $(this).attr('data-id');
            if(confirm('确定删除？')){
                var obj = $(this).parent('div');
                del_book(ac_id,obj);
            }
        })
    });
    function del_book(id,obj){
        $.ajax({
            type:'delete',
            url:'/bookmarkers/'+id+'.html',
            dataType : 'json',
            success:function(data){
                if(data.status){
                    toastr.success(data.info);
                    obj.remove();
                }else{
                    toastr.error(data.info, 'WARING!!!!!!:');
                }
            },
            error:function(data){
                alert('AJAX操作失败');
            }
        })
    }
</script>


{/block}